package com.cxc.composite;


import java.util.ArrayList;
import java.util.List;

public class Folder  implements AbstractFile{

    String name = "";
    List<AbstractFile>  listFile = new ArrayList<>();


    public Folder(String name) {
        this.name = name;
    }

    public void add(AbstractFile file){
        listFile.add(file);
    }
    public void  remove(AbstractFile file){
        listFile.remove(file);
    }
    public AbstractFile getChild(int index){
        return listFile.get(index);
    }

    @Override
    public void antivirus() {
        System.out.println("---文件夹："+name+",进行查杀");
        for (AbstractFile file:listFile){
            file.antivirus();
        }
    }
}


class TextFile implements AbstractFile{
    String name;
    public TextFile(String name) {
        this.name = name;
    }
    @Override
    public void antivirus() {
        System.out.println("查杀文本-->"+name);

    }
}
class ImgFile implements AbstractFile{
    String name;
    public ImgFile(String name) {
        this.name = name;
    }

    @Override
    public void antivirus() {
        System.out.println("查杀图片->>"+name);

    }
}
class MediaFile implements AbstractFile{
    String name;
    public MediaFile(String name) {
        this.name = name;
    }
    @Override
    public void antivirus() {
        System.out.println("查杀视频-->"+name);

    }
}
